import { reqCategoryList, reqGetBannerList, reqFloorList } from '@/api'
const state = {
  categoryList: [],
  bannerList: [],
  reqFloorList: []
}

const mutations = {
  CATEGORY (state, categoryList) {
    state.categoryList = categoryList
  },
  BANNER (state, bannerList) {
    state.bannerList = bannerList
  },
  FLOOR (state, reqFloorList) {
    state.reqFloorList = reqFloorList
  }
}
const actions = {
  async categoryList ({ commit }) {
    const result = await reqCategoryList()
    console.log(result)
    if (result.code === 200) {
      commit('CATEGORY', result.data)
    }
  },
  async reqGetBannerList ({ commit }) {
    // 异步请求
    const result1 = await reqGetBannerList()
    console.log('开始异步请求数据')
    console.log(result1)
    if (result1.code === 200) {
      commit('BANNER', result1)
    }
  },
  async reqFloorList ({ commit }) {
    const result2 = await reqFloorList()
    if (result2.code === 200) {
      commit('FLOOR', result2.data)
    }
  }
}
const getters = {}

export default {
  state,
  actions,
  getters,
  mutations
}
